<?php
include 'conn_mysql.php';
//查询地方信息
$sql="SELECT * FROM `lvyou_difang_info` WHERE id='".$id_difang."'";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)){
	$difang_name=$row['difang_name'];
	$biaoti=$row['biaoti'];
	$jiage=$row['jiage'];
	$jitian=$row['jitian'];
	$fanduos=$row['fanduos'];
	$picture_lujing=$row['picture_lujing'];
	$danfangcha=$row['danfangcha'];
}
//查询该用户的单人房数
$sql="SELECT * FROM `main_user` WHERE id_self='".$id_main."'";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)){
	$num=$row['num'];
}
?>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, maximum-scale=1, user-scalable=no">
    <title>驴行天下</title>
    <link href="bootstrap.min.css" rel="stylesheet">
    <link href="style.css" rel="stylesheet" type="text/css">
	<script language="javascript" src="js/jquery.min182.js"></script>
	<script language="javascript" src="js/jquery.form.js"></script>
	<script language="javascript" src="js/json.parse.js"></script>
    <script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>

		<?php
		//查看订单是否已取消或已支付
		if($id_main)
		{
			$sql="select id_self,is_zhifu from main_user where id_self='$id_main' ";
			$query = mysql_query($sql);
			while($row = mysql_fetch_array($query)){
				$this_id_self=$row['id_self'];
				$is_zhifu=$row['is_zhifu'];
			}
			if(!$this_id_self)
			{
				echo "<SCRIPT>alert('订单不存在');window.history.go(-1);</SCRIPT>";
				exit;
			}

			if($is_zhifu>0)
			{
				echo "<SCRIPT>alert('订单已支付或已取消无法添加游客');window.history.go(-1);</SCRIPT>";
				exit;
			}
		}


	?>
	
<!--header-->
<div class="header_title">
	<!--<p>【贵州精华】2016全年贵州：西江千户苗寨-朗德上寨-荔波小七孔-黄果树瀑布-青岩古镇，奇山秀水、苗家风情之旅6日团</p>-->
	<p><?php echo $biaoti;?></p><!--旅游项目标题-->
</div>
<!--plate-->
<div class="plate">
	<h1>单房差</h1>
    <div class="plate_line">
    	<div class="plate_line_name">单房差价格：</div>
        <div class="plate_line_name">
        	<a><?php echo $danfangcha.".00元";?></a>
        </div>
    </div>
    <div class="plate_line">
    	<div class="plate_line_name">单房数目：</div>
        <div style="height:40px;width:60%;float:right;border:1px solid #dcdddd; border-radius:4px; overflow:hidden">
        	<input style="width:100%; padding-left:10px;font-size:17px; margin-top:7px;border:none" type="number" placeholder="请填写房间数量" id="num" value="<?php echo $num;?>">
        </div>
    </div>
</div>

<a class="button" style="margin-bottom:10px" onclick="tianjiayouke();"><input type="submit" value="提交"></a>
</body>
<script>
function intOnly(){
  var codeNum=event.keyCode;
  if(codeNum==8||codeNum==37||codeNum==39||(codeNum>=48&&codeNum<=57)){
    event.returnValue=codeNum;
  }else{
    event.returnValue=false;
  }
}

//添加游客
function tianjiayouke(){
	var num      =      document.getElementById("num").value;
	
	if(num<0){
		alert('单房数量不允许小于0！');
		return;
	}
	
	var url="getmessage_all.php?bigtype=4";
	url=url+"&id=<?php echo $_REQUEST['id'];?>";
	url=url+"&num="+num;

	$.ajax({
		type:"GET",
		url:url,
		dataType: "json",
		success: function(data){	
			if(data['code']==0001){
				//alert("数据成功上传！");
				window.location.href='index_pay.php';
			}else{
				
			}
		},
		error:function(){
			alert("123");
		}
	});
	
}

</script>
</html>
